home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlib43 / mntlib / close.c < prev    next >
C/C++ Source or Header  |  1993-07-06  |  428b  |  30 lines

  1. /*
  2.  * close(): close a file. written by Eric R. Smith and placed in the public
  3.  * domain
  4.  */
  5.  
  6. #include <osbind.h>
  7. #include <fcntl.h>
  8. #include <errno.h>
  9. #include <unistd.h>
  10. #include "lib.h"
  11.  
  12. int
  13. close(fd)
  14.     int fd;
  15. {
  16.     int r;
  17.  
  18.     r = Fclose(fd);
  19.     if (r < 0) {
  20.         errno = -r;
  21.         return -1;
  22.     }
  23.     fd = __OPEN_INDEX(fd);
  24.     if (fd >= 0 && fd < __NHANDLES) {
  25.         __open_stat[fd].status = FH_UNKNOWN;
  26.         __open_stat[fd].flags = 0;
  27.     }
  28.     return 0;
  29. }
  30.